import pandas as pd

# 读取原始CSV文件
df = pd.read_csv('game.csv')

# 选择需要的列
selected_columns = [
    'season_id',
    'team_abbreviation_home',
    'team_abbreviation_away',
    'reb_home',
    'reb_away',
    'pts_home',
    'pts_away',
    'fg3m_home',
    'fg3m_away'
]

# 创建新的数据框，只包含选定的列
processed_df = df[selected_columns]

# 处理season_id：删除第一位数字
processed_df['season_id'] = processed_df['season_id'].astype(str).str[1:].astype(int)

# 筛选2000-2023年的数据
processed_df = processed_df[
    (processed_df['season_id'] >= 2000) & 
    (processed_df['season_id'] <= 2023)
]

# 保存处理后的数据到新的CSV文件
processed_df.to_csv('process_game.csv', index=False)

print("数据处理完成！新文件已保存为 process_game.csv")
